<!-- create begin -->
<div class=" create">

    <!-- 表单 -->   
    <section class="panel-body" >
            <form role="form" class="form-create">

                <div class="form-group col-sm-6">
                    <span>产品编号</span>
                    <input type="text" class="form-control" placeholder="产品编号" name="sn" value="{:date('Ymdhis').rand(100,999)}">
                </div>

                <div class="form-group col-sm-6">
                    <span>内部编号</span>
                    <input type="text" class="form-control" placeholder="内部编号" name="unique_sn">
                </div>

                <div class="form-group col-sm-6">
                    <span>产品分类</span>
                    <select name="cate" class="form-control comboSelect">
                        <option value="0">顶级</option>
                        {volist name="list" id="vo"}
                            {if($vo.level<2) }
                                <option value="{$vo.id}">{:$vo.level>0? '|' : null }{:str_repeat('--',$vo.level)}{$vo.name}
                                </option>
                            {else /} {/if}

                        {/volist}
                    </select>
                </div>

                <div class="form-group col-sm-6">
                    <span>产品名称</span>
                    <input type="text" class="form-control" placeholder="产品名称" name="name">
                </div>


                <div class="form-group col-sm-6">
                    <span>品牌</span>
                    <select name="brand" class="form-control comboSelect">
                        {volist name="brand" id="vo"}
                            <option value="{$vo.id}" >{$vo.name}</option>
                        {/volist}
                    </select>
                </div>

                <div class="form-group col-sm-6">
                    <span>型号</span>
                    <input type="text" class="form-control" placeholder="型号" name="model">
                </div>   

                <div class="form-group col-sm-6">
                    <span>规格</span>
                    <input type="text" class="form-control" placeholder="规格" name="spec">
                </div> 

                <div class="form-group col-sm-6">
                    <span>默认价格</span>
                    <input type="text" class="form-control" placeholder="默认价格" name="price">
                </div> 

                <div class="form-group col-sm-6">
                    <span>默认供应商</span>
                    <select name="supplier" class="form-control comboSelect">
                        {volist name="supplier" id="vo"}
                            <option value="{$vo.id}" >{$vo.title}</option>
                        {/volist}
                    </select>
                </div>

                <div class="form-group col-sm-6">
                    <span>默认客户</span>
                    <select name="customer" class="form-control comboSelect">
                        {volist name="customer" id="vo"}
                            <option value="{$vo.id}" >{$vo.title}</option>
                        {/volist}
                    </select>
                </div>

                <div class="form-group col-sm-6">
                    <span>默认库位</span>
                    <select name="location" class="form-control comboSelect" >
                        <!-- location -->
                        {volist name="location" id="vo"}
                        <option value="{$vo.id}" >{$vo.name}</option>
                        {/volist}
                    </select>
                </div>                             

                <div class="form-group col-sm-6">
                    <span>计量单位</span>
                    <select name="unit" class="form-control comboSelect">
                        {volist name="unit" id="vo"}
                            <option value="{$vo.id}" >{$vo.name}</option>
                        {/volist}
                    </select>
                </div>    

                <div class="form-group col-sm-6">
                    <span>颜色</span>
                    <select name="color" class="form-control comboSelect">
                        {volist name="color" id="vo"}
                            <option value="{$vo.id}" >{$vo.name}</option>
                        {/volist}
                    </select>
                </div>

                <!-- <div class="form-group col-sm-12">
                    <span>备注</span>
                    <textarea class="form-control" cols="5" name="desc"></textarea>
                </div> -->

            </form>
    </section>

    <div class="form-group col-sm-12 panel-footer bg-none">
        <button type="button" class="btn btn-sm btn btn-primary" @click="save">  保 存 </button>
        <button type="reset" class="btn btn-sm btn-success ">  重 置 </button> 
    </div>
    

</div>
<!-- create end-->

<script>

// seajs
seajs.use(['vendor/comboSelect/jquery.combo.select'],function() {

    var create = new Vue({
        el: '.create',
        data: {},
        mounted: function(){
            var _this = this;
            $('.comboSelect').comboSelect();

        },
        methods: {
            save: function () {
                var param = $('.form-create').serializeArray();
                $.ajax({
                    url: "{:url('save')}",
                    method: 'POST',
                    dataType: 'json',
                    data: param,
                    success: this.callback
                });
            },
            callback:function (data) {
                if( data.error >0 ){
                    toastr.error(data.msg);
                }else{
                    toastr.success(data.msg);
                    Table.methods.refresh();
                    layer.closeAll('page');
                }
            }
        }

    });

});

</script>